package com.buptse.utils;

import com.buptse.dao.CityMapper;
import com.buptse.model.City;
import com.buptse.model.Information;

import java.math.BigDecimal;

public class LocationDecoder {
    public static void locationDecode(String code, CityMapper cityMapper, Information information){
        int tableIndex;
        if((code.compareTo("110101001001")>0)&&(code.compareTo("131127203201")<0)){
            tableIndex=0;
        } else if ((code.compareTo("131127203203")>0)&&(code.compareTo("222406102202")<0)) {
            tableIndex=1;
        } else if ((code.compareTo("222406102204")>0)&&(code.compareTo("331082103248")<0)) {
            tableIndex=2;
        } else if ((code.compareTo("331082103250")>0)&&(code.compareTo("370126102235")<0)) {
            tableIndex=3;
        } else if ((code.compareTo("370126102238")>0)&&(code.compareTo("410328213212")<0)) {
            tableIndex=4;
        } else if ((code.compareTo("410328213214")>0)&&(code.compareTo("421223102220")<0)) {
            tableIndex=5;
        } else if ((code.compareTo("421223103200")>0)&&(code.compareTo("510185009202")<0)) {
            tableIndex=6;
        } else if ((code.compareTo("510185009204")>0)&&(code.compareTo("540224208203")<0)) {
            tableIndex=7;
        }else {
            tableIndex=8;
        }
        City city=cityMapper.selectCity("city"+tableIndex,code);
        information.setLocation(city.getProvince()+" "+city.getCity()+" "+city.getCounty()+" "+city.getTown()+" "+city.getVillage());
    }
}
